package com.api.syh56.shengyunhui.entity;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.ColumnComment;
import com.gitee.sunchenbin.mybatis.actable.annotation.DefaultValue;
import lombok.*;
import lombok.experimental.FieldDefaults;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 发票
 */
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
@TableName("invoice")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Invoice {
    @Column(name = "id",isAutoIncrement = true,isKey = true)
    Long id;

    @Column(name = "invoice_num",comment = "发票号码 后台工作人员填写")
    String invoiceNum;

    @Column(name = "title_type",comment = "抬头类型")
    Short titleType;

    @Column(name = "company_name",comment = "公司名称")
    @DefaultValue(value = "")
    String companyName;

    @Column(name = "tax_num",comment =  "税号")
    @DefaultValue(value = "")
    String taxNum;

    @Column(name = "reg_address",comment = "注册地址")
    @DefaultValue(value = "")
    String regAddress;

    @Column(name = "reg_phone",comment = "注册电话")
    @DefaultValue(value = "")
    String regPhone;

    @Column(name = "bank_name",comment = "开户行")
    @DefaultValue(value = "")
    private String bankName;

    @Column(name = "bank_account",comment = "银行账号")
    @DefaultValue(value = "")
    private String bankAccount;

    @Column(name = "invoice_content",comment = "发票内容")
    @DefaultValue(value = "")
    String invoiceContent;

    @Column(name = "postscript",comment = "备注信息")
    @DefaultValue(value = "")
    String postscript;

    @Column(name = "goods_name",comment = "货物")
    @DefaultValue(value = "")
    String goodsName;

    @Column(name = "specification_type",comment = "规格类型")
    @DefaultValue(value = "")
    String specificationType;

    /**
     * 0=份
     * 1=单
     */
    @Column(name = "unit",comment = "单位")
    String unit;

    @Column(name = "goods_num") // 数量
    @ColumnComment("货物数量")
    double goodsNum;

    @Column(name = "tax_rate",comment = "税率")
    BigDecimal taxRate;

    /**
     * 税前金额 = 含税价 - 税额
     */
    @Column(name = "u_amount",comment = "税前金额")
    BigDecimal uAmount;

    /**
     * 税额 = 含税价 * 税率
     */
    @Column(name = "tax_amount",comment = "税额")
    BigDecimal taxAmount;

    /**
     * 含税价 = 报价金额
     */
    @Column(name = "total_amount",comment = "含税价")
    @DefaultValue(value = "0")
    BigDecimal totalAmount;

    /**
     *  服务费
     */
    @Column(name = "service_charge",comment = "服务费")
    BigDecimal serviceCharge;

    /**
     * 总税额
     */
    @Column(name = "total_tax_amount",comment = "总税额")
    BigDecimal totalTaxAmount;

    @Column(name ="invoice_url",comment = "发票图片  后台工作人员填写")
    String invoiceUrl;

    @Column(name = "mailbox",comment = "邮箱地址")
    String mailbox;

    @Column(name = "uid",comment = "用户id")
    Long uid;

    @Column(name = "wid_list",comment = "运单id")
    String widList;

    @Column(name = "title_id",comment = "抬头ID")
    Long titleId;

    @Column(name = "admin_user_id",comment = "管理员id")
    Long adminUserId;

    @TableField(fill = FieldFill.INSERT)
    @Column(name = "creator_user_id")
    private Long creatorUserId;

    @Column(name = "creation_time")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime creationTime;

    @Column(name = "last_modification_time")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime lastModificationTime;

    @Column(name = "invoice_state",comment = "发票状态")
    Short invoiceState;

    @Column(name = "invoice_type",comment = "发票类型 0 专票 1 普票")
    Short invoiceType;

    @Column(name = "remark",comment = "备注 （退票/红冲）错误信息")
    @DefaultValue(value = "")
    String remark;

    @Column(name = "issuing_time",comment = "开具时间")
    LocalDateTime issuingTime;

    @TableLogic
    @Column(name = "is_deleted")
    @DefaultValue("false")
    private Boolean isDeleted;
}
